package com.tencent.sr.iris.activity.restapi.task;

import com.tencent.sr.iris.activity.interfaces.client.task.IrisGroupTaskClient;
import com.tencent.sr.iris.activity.interfaces.request.task.GroupTaskListNewRequest;
import com.tencent.sr.iris.activity.interfaces.request.task.GroupTaskPopRequest;
import com.tencent.sr.iris.activity.interfaces.request.task.GroupTaskRewardDetailRequest;
import com.tencent.sr.iris.activity.interfaces.request.task.GroupTaskRewardRequest;
import com.tencent.sr.iris.activity.interfaces.request.task.MarketTaskCalenderRequest;
import com.tencent.sr.iris.activity.interfaces.request.task.UserAwardInfoRequest;
import com.tencent.sr.iris.activity.interfaces.response.activity.UserAwardInfoResponse;
import com.tencent.sr.iris.activity.interfaces.response.group.task.GroupTaskConfigResponse;
import com.tencent.sr.iris.activity.interfaces.response.group.task.GroupTaskListResponse;
import com.tencent.sr.iris.activity.interfaces.response.group.task.GroupTaskPopResponse;
import com.tencent.sr.iris.activity.interfaces.response.group.task.GroupTaskRewardDetailResponse;
import com.tencent.sr.iris.activity.interfaces.response.group.task.GroupTaskRewardResponse;
import com.tencent.sr.iris.activity.service.activity.ActivityCommonService;
import com.tencent.sr.iris.activity.service.task.GroupTaskService;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import com.tencent.sr.rmall.common.request.PaginationRequest;
import com.tencent.sr.rmall.common.response.PaginationResponse;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "团长任务", value = "团长任务相关接口")
@RestController
@RequestMapping(value = {"/api/v1/iris/iris-activity-core-service/task"})
public class GroupTaskController implements IrisGroupTaskClient {

    @Resource
    private GroupTaskService groupTaskService;

    @Resource
    private ActivityCommonService activityCommonService;

    @Override
    public HttpResult<String> hello() {
        return HttpResult.succ("hello");
    }

    @Override
    public HttpResult<UserAwardInfoResponse> awardInfo(@RequestBody @Validated UserAwardInfoRequest request) {
        UserAwardInfoResponse response = activityCommonService.getAwardInfo(request);
        return HttpResult.succ(response);
    }

    @Override
    public HttpResult<GroupTaskPopResponse> pop(GroupTaskPopRequest request) {
        return HttpResult.succ(groupTaskService.pop(request));
    }

    @Override
    public HttpResult<GroupTaskConfigResponse> config() {
        return HttpResult.succ(groupTaskService.config());
    }

    @Override
    public HttpResult<GroupTaskRewardResponse> taskReward(GroupTaskRewardRequest request) {
        return HttpResult.succ(groupTaskService.taskReward(request));
    }

    @Override
    public HttpResult<PaginationResponse<GroupTaskRewardDetailResponse>> pageRewardList(
            PaginationRequest<GroupTaskRewardDetailRequest> request) {
        return HttpResult.succ(groupTaskService.pageRewardList(request));
    }

    @Override
    public HttpResult<PaginationResponse<GroupTaskListResponse>> listInProgress(
            PaginationRequest<GroupTaskListNewRequest> request) {
        return HttpResult.succ(groupTaskService.listInProgress(request));
    }

    @Override
    public HttpResult<PaginationResponse<GroupTaskListResponse>> listEnded(
            PaginationRequest<GroupTaskListNewRequest> request) {
        return HttpResult.succ(groupTaskService.listEnded(request));
    }

    @Override
    public HttpResult<List<GroupTaskListResponse>> marketCalendarList(MarketTaskCalenderRequest request) {
        return HttpResult.succ(groupTaskService.marketCalendarList(request));
    }

    @Override
    public HttpResult<UserAwardInfoResponse> getAwardInfoByActivityAndTask(UserAwardInfoRequest request) {
        return HttpResult.succ(activityCommonService.getAwardInfoByActivityAndTask(request));
    }
}

